package cn.hl.sfzy.service.impl;


import cn.hl.sfzy.entity.Heartknowledge;
import cn.hl.sfzy.mapper.HeartknowledgeMapper;
import cn.hl.sfzy.service.HeartknowledgeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class HeartknowledgeServiceImpl implements HeartknowledgeService {
    @Autowired
    private HeartknowledgeMapper heartknowledgeMapper;

    @Override
    public int add(Heartknowledge heartknowledge) {
         int i = heartknowledgeMapper.add(heartknowledge);;
        return i;
    }

    @Override
    public int deleteById(Long id) {
        return heartknowledgeMapper.deleteById(id);
    }


    @Override
    public PageInfo<Heartknowledge> findBypage(int pageNum, int pageSize,Heartknowledge heartknowledge) {
        PageHelper.startPage(pageNum, pageSize);
//        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
//        String format = outputFormat.format(heartknowledge.getCreateTimeMax());
//        System.out.println(format);
        List<Heartknowledge> select = heartknowledgeMapper.findAll(heartknowledge);
        PageInfo pageHelper = new PageInfo<Heartknowledge>(select);
        return pageHelper;
    }

    @Override
    public int update(Heartknowledge heartknowledge){
        int update = heartknowledgeMapper.update(heartknowledge);
        return update;
    }
}
